// 对API统一管理
import request from './request'
import requestMock from '@/api/mock'

/**
 * 获取3级分离类
 * @returns 
 */
export const reqCategoryList = ()=>{
  //发请求
  return request({
    url:'/product/getBaseCategoryList',
    method:'get',
  })
}

/**
 * 请求首页轮播图数据
 * @returns {Promise}
 */
 export const reqBannerList = () => requestMock.get('/banner')

 /**
 * 请求楼层数据
 * @returns {Promise}
 */
export const reqFloorList = () => requestMock.get('/floor')

/**
 * 获取搜索数据
 * @param data 
 * @returns 
 */
export const reqGetSearchInfo = (data) =>{
  return request({
    url: '/list',
    method: 'post',
    data: data
  })
}

/**
 * 获取商品详情数据
 * @param skuId 
 * @returns 
 */
export const reqGetGoodsInfo = (skuId) => {
  return request({
    url: `/item/${skuId}`,
    method: 'get'
  })
}

/**
 * 添加或修改购物车数量
 * @param {*} skuId 
 * @param {*} skuNum 
 * @returns 
 */
export const reqAddOrUpdateCartNum = (skuId,skuNum) => {
  return request({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: 'POST'
  })
}

/**
 * 获取购物车列表
 * @returns 
 */
export const reqCartList = () => {
  return request({
    url: `/cart/cartList`,
    method: 'get'
  })
}

/**
 * 根据skuid删除购物车商品
 * @param skuId 
 * @returns 
 */
export const reqDeleteCartBySkuId = (skuId) => {
  return request({
    url: `/cart/deleteCart/${skuId}`,
    method: 'delete',
  })
}

/**
 * 切换购物车选中后状态
 * @param skuId 
 * @param isChecked 
 * @returns 
 */
export const reqUpdateCheckedById = (skuId,isChecked) => {
  return request({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'get',
  })
}

/**
 * 获取手机验证码
 * @param phone 
 * @returns 
 */
export const reqGetcode = (phone) => {
  return request({
    url: `/user/passport/sendCode/${phone}`,
    method: 'get',
  })
}

/**
 * 注册
 * @param data 
 * @returns 
 */
export const reqRegister = (data) => {
  return request({
    url: `/user/passport/register`,
    method: 'post',
    data: data
  })
}

/**
 * 登录
 * */ 
export const reqLogin = (data) => {
  return request({
    url: '/user/passport/login',
    method: 'post',
    data: data
  })
}

/**
 * 获取用户信息
 * @returns 
 */
export const reqUserInfo = () => {
  return request({
    url: '/user/passport/auth/getUserInfo',
    method: 'get'
  })
}

/**
 * 退出登录
 * @returns 
 */
export const reqLogout = () => {
  return request({
    url:'/user/passport/logout',
    method:"get"
  })
}

/**
 * 获取用户地址信息
 * @returns
 */
export const reqGetAdressList = ()=> {
  return request({
    url:'/user/userAddress/auth/findUserAddressList',
    method:"get"
  })
}

/**
 * 获取交易页信息
 * @returns 
 */
export const reqGetTrade = () => {
  return request({
    url:'/order/auth/trade',
    method:"get"
  })
}

/**
 * 提交订单
 * @returns 
 */
 export const reqSubmitOrder = (tradeNo,data) => {
  return request({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: "post",
    data
  })
}

/**
 * 获取订单信息
 */
 export const reqPayInfo = (orderId) => {
  return request({
    url: `/payment/weixin/createNative/${orderId}`,
    method: "get"
  })
}

/**
 * 获取订单状态
 * @param orderId 
 * @returns 
 */
export const reqPayStatus = (orderId) => {
  return request({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: "get"
  })
}

/**
 * 获取我的订单
 * @param page 
 * @param limit 
 * @returns 
 */
export const reqMyOrderList = (page,limit) => {
  return request({
    url: `/order/auth/${page}/${limit}`,
    method: "get"
  })
}